<!DOCTYPE html>
<html>
<head>
<title>用户删除</title>
<#include "/header.html">
</head>
<body>
<div id="rrapp" v-cloak>
<div class="panel panel-default">
	<form class="form-horizontal">
		<div class="form-group">
			<div class="col-sm-5">
				<input type="text" id="userId" class="form-control"  placeholder="用户Id"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-5">
				<input type="button" class="btn btn-primary" onclick=openUser() value="确定"/>
			</div>
		</div>
	</form>
</div>
<div v-show="!showList" class="panel panel-default" id="userInfo">
	<form class="form-horizontal">
		<div class="form-group">
			<div class="col-sm-2 control-label">用户ID</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.userId" placeholder="用户ID" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">用户昵称</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.nickName" placeholder="用户昵称" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">微信头像</div>
			<div class="col-sm-10">
				<img v-bind:src="bUserInfo.avatarUrl" width="200px" height="200px"></img>
			</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">邀请人</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.referer" placeholder="无" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">VIP到期时间</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.vipTime" placeholder="" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">创建时间</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.createTime" placeholder="创建时间" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label">最近活跃时间</div>
			<div class="col-sm-10">
				<input type="text" class="form-control" v-model="bUserInfo.modifyTime" placeholder="最近活跃时间" readonly="readonly"/>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label"></div>
			<input type="button" class="btn btn-primary" onclick="delUser()" value="删除" id="ok"/>
		</div>
	</form>
</div>
</div>
</body>
<script>
	function openUser() {
		var userId=$("#userId").val().trim();
		vm.getInfo(userId);
	}
	var vm = new Vue({
		el:'#rrapp',
		data:{
			showList: true,
			bUserInfo:{}
		},
		methods: {
			getInfo: function (userId) {
				$("#vip").empty();
				$("#vipStatus").empty();
				$.get(baseURL + "sys/buserinfo/info/" + userId, function (r) {
					if(r.code==0) {
						vm.bUserInfo = r.bUserInfo;
						$("#vip").append(
								"<option value=" + 4 + ">" + '请选择' + "</option>");
						$("#vip").append(
								"<option value=" + 1 + ">" + '半年' + "</option>");
						$("#vip").append(
								"<option value=" + 2 + ">" + '一年' + "</option>");
						$("#vip").append(
								"<option value=" + 3 + ">" + '三年' + "</option>");
						$("#vip").find("option[value='" + 4 + "']").attr("selected", true);
						var status = vm.bUserInfo.vipStatus;
						if (status == "" || status == null) {
							status = 0;
						}
						$("#vipStatus").append(
								"<option value=" + 1 + ">" + '是' + "</option>");
						$("#vipStatus").append(
								"<option value=" + 0 + ">" + '否' + "</option>");
						$("#vipStatus").find("option[value='" + status + "']").attr("selected", true);
						vm.showList=false;
					}else{
						alert(r.msg);
						return;
					}
				});
			}
		}
		})

	function delUser() {
		var userId=$("#userId").val().trim();
		confirm('确定要删除用户'+userId+'吗？', function() {
			$.ajax({
				type: "POST",
				url: baseURL + "sys/buserinfo/delete",
				contentType: "application/json",
				data: JSON.stringify(userId),
				success: function (r) {
					if (r.code == 0) {
						alert('操作成功', function (index) {
							window.location.reload();
						});
					} else {
						alert(r.msg);
					}
				}
			});
		});
	}
</script>
</html>